    //
//  LSButton.m
//  NetworkingSevers
//
//  Created by Samuel on 14-4-12.
//
//

#import "LSButton.h"

@implementation LSButton

- (id)initWithFrame:(CGRect)frame buttonStyle:(GLSButton)buttonStyle
{
    self = [super initWithFrame:frame];
    if (self)
    {
        if (buttonStyle == 0)
        {
//            [self setFlickerButton];
        }
    }
    return self;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
}
*/
- (void)setTimeInterval:(float)onceTimes maxAlpha:(float)maxValue lessAlpha:(float)lessValue repeats:(BOOL)repetTimes;
{
    averageAlpha = onceTimes/(maxValue+lessValue);
    maxAlpha = maxValue;
    lessAlpha = lessValue;
    colorAlpha = 1;
    
    buttonAct = [NSTimer scheduledTimerWithTimeInterval:onceTimes target:self selector:@selector(changeAlpha) userInfo:nil repeats:repetTimes];
}
- (void)changeAlpha
{
    if (buttonTag==NO)
    {
        colorAlpha=colorAlpha-averageAlpha;
        buttonTag = NO;
    }
    if(buttonTag==YES)
    {
        colorAlpha=colorAlpha+averageAlpha;
    }
    if (colorAlpha>=maxAlpha)
    {
        buttonTag = NO;
    }
    if (colorAlpha<=lessAlpha)
    {
        buttonTag = YES;
    }
    [self setAlpha:colorAlpha];
}
- (void)stopFlicker
{
    [buttonAct setFireDate:[NSDate distantFuture]];
}
- (void)startFlicker
{
    [buttonAct setFireDate:[NSDate date]];
}
@end
